package arrays;

import java.util.Arrays;

public class EX19 implements Comparable<EX19>{

	int inta;
	
	public EX19(int inta){
		this.inta = inta;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + inta;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final EX19 other = (EX19) obj;
		if (inta != other.inta)
			return false;
		return true;
	}
	
	public String toString(){
		return "EX19 : " + inta;
	}
	
	public static void main(String[] args) {
		EX19[] ex19Arrays1 = new EX19[]{new EX19(1),new EX19(2)};
		EX19[] ex19Arrays2 = new EX19[]{new EX19(1),new EX19(2)};
		System.out.println(Arrays.equals(ex19Arrays1, ex19Arrays2));
		
		EX19 ex19a = new EX19(1);
		EX19 ex19b = ex19a;
		System.out.println(ex19a==ex19b);
		
		EX19[][] ex19DeepArray1 = new EX19[2][2];
		EX19[] ex19Arrays3 = null;
		for(int i = 0; i < ex19DeepArray1.length; i++){
			ex19Arrays3 = ex19DeepArray1[i];
			for(int j = 0; j < ex19Arrays3.length; j ++)
				ex19Arrays3[j] = new EX19(1);
		}
		EX19[][] ex19DeepArray2 = new EX19[][]{{new EX19(1), new EX19(1)}, {new EX19(1), new EX19(1)}};
		System.out.println(Arrays.deepEquals(ex19DeepArray1, ex19DeepArray2));
	}

	public int compareTo(EX19 o) {
		return (this.inta < o.inta)?-1:(this.inta == o.inta ? 0 : 1);
	}
}
